package com.xiaohe.gulimall.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public class OrderConfirmVo {

    //收获地址
    //ums_member_receive_address
    List<MemberAddressVo> addressVos;


    //所有购物项
    List<OrderItemVo> items;


    //发票信息。。

    //优惠劵信息
    private Integer integration;

    @Setter@Getter
    private Map<Long,Boolean> stocks;

    //订单总额
    private BigDecimal total;

    private BigDecimal payPrice;

    //TODO
    private boolean hasStock;

    private BigDecimal weight;


    //防重令牌
    private String OrderToken;


    public Integer getCount(){
        Integer i =0;
        for (OrderItemVo item : items) {
            i+=item.getCount();
        }
        return i;
    }

    public String getOrderToken() {
        return OrderToken;
    }

    public void setOrderToken(String orderToken) {
        OrderToken = orderToken;
    }

    public List<MemberAddressVo> getAddressVos() {
        return addressVos;
    }

    public void setAddressVos(List<MemberAddressVo> addressVos) {
        this.addressVos = addressVos;
    }

    public List<OrderItemVo> getItems() {
        return items;
    }

    public void setItems(List<OrderItemVo> items) {
        this.items = items;
    }

    public Integer getIntegration() {
        return integration;
    }

    public void setIntegration(Integer integration) {
        this.integration = integration;
    }

    public BigDecimal getTotal() {
        BigDecimal sum = new BigDecimal("0");
        if (items!=null){
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                sum = sum.add(multiply);
            }
        }
        return sum;
    }

    public void setTotal(BigDecimal total) {
        this.total = total;
    }

    public BigDecimal getPayPrice() {
        BigDecimal sum = new BigDecimal("0");
        if (items!=null){
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                sum = sum.add(multiply);
            }
        }
        return sum;
    }

    public void setPayPrice(BigDecimal payPrice) {

        this.payPrice = payPrice;
    }
}
